//
//  StatisticsViewController.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/22.
//

#import "StatisticsViewController.h"
#import "CommonUtil.h"
#import "myStatisticsView.h"
#import "TabView.h"
#import "AllstatisticsView.h"

@interface StatisticsViewController ()

@property (strong, nonatomic) TabView * tabView;
@property (strong, nonatomic) UIScrollView * contentView;
@property (strong, nonatomic) myStatisticsView * myView;
@property (strong, nonatomic) AllstatisticsView * allView;
@property (strong, nonatomic) AllstatisticsView * expertView;
@end

@implementation StatisticsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.edgesForExtendedLayout = UIRectEdgeNone; //从导航栏下布局
    self.navigationItem.title = @"统计";

    [self.view addSubview:self.tabView];
    [self.view addSubview:self.contentView];
    [self.contentView addSubview:self.myView];
    [self.contentView addSubview:self.allView];
    [self.contentView addSubview:self.expertView];
}




- (void)btnClick:(UIButton *)sender{
    
    if ([sender.titleLabel.text isEqualToString:@"我的统计"]) {
        [self.contentView setContentOffset:CGPointMake(0, 0) animated:YES];
    }else if ([sender.titleLabel.text isEqualToString:@"全网统计"]){
        [self.contentView setContentOffset:CGPointMake(SCREEN_WIDTH, 0) animated:YES];
    }else if ([sender.titleLabel.text isEqualToString:@"专家统计"]){
        [self.contentView setContentOffset:CGPointMake(SCREEN_WIDTH*2, 0) animated:YES];
    }
}


#pragma mark - lazy

- (TabView *)tabView{
    if (!_tabView) {
        _tabView = [[TabView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, AD(35))];
        [_tabView.myStatistics addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_tabView.allStatistics addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_tabView.expertStatistics addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _tabView;
}

-(UIScrollView *)contentView{
    if (!_contentView) {
        _contentView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, _tabView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT- kNavBarHeight - kStatusBarHeight-_tabView.height)];
        _contentView.contentSize = CGSizeMake(SCREEN_WIDTH * 3, 0);
        _contentView.pagingEnabled = YES;
    }
    return _contentView;
}

-(myStatisticsView *)myView{
    if (!_myView) {
        CGFloat h = SCREEN_HEIGHT- kNavBarHeight - kStatusBarHeight - _tabView.height;
        _myView = [[myStatisticsView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, h)];
    }
    return _myView;
}


-(AllstatisticsView *)allView{
    if (!_allView) {
        CGFloat h = SCREEN_HEIGHT- kNavBarHeight - kStatusBarHeight - _tabView.height;
        _allView = [[AllstatisticsView alloc] initWithFrame:CGRectMake(_myView.right, 0, SCREEN_WIDTH, h)];

    }
    return _allView;
}

-(AllstatisticsView *)expertView{
    if (!_expertView) {
        CGFloat h = SCREEN_HEIGHT- kNavBarHeight - kStatusBarHeight - _tabView.height;
        _expertView = [[AllstatisticsView alloc] initWithFrame:CGRectMake(_allView.right, 0, SCREEN_WIDTH, h)];
    }
    return _expertView;
}



@end
